import {getRequest} from "./request";

/*登录请求*/
export function requestVerify(userName,passwordLog){
  return getRequest({
    url:"select",
    method:"post",
    params: {
      username: userName,
      passwordlog: passwordLog
    }
  });
}
/**/
export function homedata(config) {
  return getRequest(config);
}

/*注册请求*/
export function requestSign(userName,uPhonenum,userPwd){
  return getRequest({
    url:'insert',
    method:'post',
    params:{
      username: userName,
      uphonenum: uPhonenum,
      userpwd: userPwd
    }
  });
}

/**
 * 页头数据请求
 * @returns {AxiosPromise}
 */
export  function requestProductTypeData() {
  return getRequest({
    url: "api/homedata",
    method: "get"
  })
}

/**
 * 详情页面数据
 * @param comId
 * @returns {AxiosPromise}
 */
export function requestDetailData(comId) {
  return getRequest({
    url: "api/detailMsg",
    method: "get",
    params: {
      comId: comId
    }
  })
}

/**
 * 首页商品展示数据请求
 */
export function requestHomeComShow() {
  return getRequest({
    url: "api/one",
    method: "get"
  })
}

/**
 * 请求后台所有商品信息，统一保存到detail中
 * @returns {*}
 */
export function requestAllComMsg() {
  return getRequest({
    url: "api/getAllComMsg",
    method: "get"
  })
}

/**
 * 保修服务 ServiceMsg.js
 */
export function requestServiceMsg() {
  return getRequest({
    url: "api/selectAllKeep",
    method: "get"
  })
}

/**
 * 请求获取购物车所有数据
 * @param userId
 * @returns {*}
 */
export function requestShoppingCartGetAllData(userId) {
  return getRequest({
    url: "api/getCarAllData",
    method: "get",
    params: {
      userId: userId
    }
  })
}

/**
 * 删除购物车中商品的方法
 * @param userId
 * @param comId
 * @returns {AxiosPromise}
 */
export function deleteShoppingCarMsgByComIdAndUserId(userId,comId) {
  return getRequest({
    url: "api/deleteShoppingCarMsgByComIdAndUserId",
    method: "get",
    params: {
      userId: userId,
      comId: comId
    }
  })
}

/**
 * 添加购物车商品信息的方法
 * @param tempData
 * @returns {AxiosPromise}
 */
export function addShoppingCarData(tempData) {
  return getRequest({
    url: "api/addShoppingCarMsg",
    method: "get",
    params: {
      userid: tempData.userId,
      comid: tempData.comId,
      shoppingnum: tempData.proNum,
      keepsetserid: tempData.serviceId,
    }
  })
}

/**
 * 修改购物车对应商品的数量
 * @param userId
 * @param comId
 * @param shoppingNum
 * @returns {AxiosPromise}
 */
export function updateShoppingCarData(userId,comId,shoppingNum) {
  return getRequest({
    url: "api/updateShoppingCarData",
    method: "get",
    params: {
      userid: userId,
      comid: comId,
      shoppingnum: shoppingNum
    }
  })
}

/**
 * 请求获取地址信息通过用户编号
 * @param userId
 * @returns {AxiosPromise}
 */
export function requestShippingAdsMsgByUserId(userId) {
  return getRequest({
    url: "api/requestShippingAdsMsgByUserId",
    method: "get",
    params: {
      userId: userId
    }
  })
}

/**
 * 请求修改用户地址信息
 * @param temp
 * @returns {*}
 */
export function requestUpdateShippingAdsMsg(temp,userId) {
  return getRequest({
    url: "api/updateShippingCarAdsMsg",
    method: "get",
    params: {
      adressmsgid: temp.adressMsgId,
      contphone: temp.contPhone,
      contname: temp.contName,
      areaadress: temp.areaAdress,
      careadress: temp.careAdress,
      selectstatus: temp.selectStatus,
      userid: userId
    }
  })
}

/**
 * 请求修改用户地址信息
 * @param temp
 * @returns {*}
 */
export function requestAddShippingAdsMsg(temp,userId) {
  return getRequest({
    url: "api/addShippingAdsMsg",
    method: "get",
    params: {
      contphone: temp.contPhone,
      contname: temp.contName,
      areaadress: temp.areaAdress,
      careadress: temp.careAdress,
      selectstatus: temp.selectStatus,
      userid: userId
    }
  })
}

/**
 * 请求删除用户地址信息
 * @param temp
 * @returns {*}
 */
export function requestDeleteShippingAdsMsg(adressmsgid,userId) {
  return getRequest({
    url: "api/deleteShippingAdsMsg",
    method: "get",
    params: {
      adressmsgid: adressmsgid,
      userid: userId
    }
  })
}

/**
 * 请求订单数据
 * @param userId
 * @returns {AxiosPromise}
 */
export function requestOrderDataByUserId(userId) {
  return getRequest({
    url: "api/getOrderDataByUserId",
    method: "get",
    params: {
      userId: userId
    }
  })
}

/**
 * 这是订单商品信息请求
 * @param userId
 * @returns {AxiosPromise}
 */
export function requestOrderComMsgDataByUserId(orderIds){
  return getRequest({
    url: "api/getOrderComMsgDataByOrderIds",
    method: "post",
    params: {
      orderIds: orderIds
    }
  })
}

/**
 * 为订单表添加信息，在提交订单时
 * @param temp
 * @returns {*}
 */
export function requestAddOrderMsg(temp) {
  return getRequest({
    url: "api/addOrderMsg",
    method: "post",
    params: {
      ...temp
    }
  })
}


/**
 * 添加订单商品数据
 */
export function requestAddOrderComMsgData(temp) {
  return getRequest({
    url: "api/addOrderComMsgData",
    method: "post",
    params: {
      ...temp
    }
  })
}

/**
 * 请求删除商品购物车信息
 * @param comIds
 * @param userId
 * @returns {AxiosPromise}
 */
export function requestDeleteShoppingCarMg(comIds,userId) {
  return getRequest({
    url: "api/deleteShoppingCarMg",
    method: "post",
    params: {
      comIds,
      userId
    }
  })
}

/**
 * 支付宝的支付方法
 * @param money
 * @param description
 * @returns {AxiosPromise}
 */
export function zhifubaoAlipay(money,description) {
  return getRequest({
    url: "api/aliapy",
    method: "get",
    params: {
      money,
      description
    }
  })
}

/**
 * 订单超时的时候，判断该订单是否已经支付，或者直接点击订单的取消，都是通过该方法发送请求
 * @param orderId
 * @returns {AxiosPromise}
 */
export function updateOrderStatus(orderId) {
  return getRequest({
    url: "api/updateOrderStatus",
    method: "post",
    params: {
      orderId
    }
  })
}


